home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Apple Script
/
OSAX
/
Finder Scripting Toolkit v1.0
/
fwin coercion osax
/
long2fwin.c
< prev
next >
Wrap
Text File
|
1993-07-20
|
2KB
|
77 lines
/*
F W I N C O E R C I O N O S A X
Version 1.0
Freeware by Daniel Ranson
This osax performs coercions to the FinderWindow (fwin) record
type used by Finder events.
There are actually three osax. This one converts integers, as a
special way to refer to the About and Clipboard windows.
The possible values are :
1 : about window
2 : clipboard window
*/
#include <Types.h>
#include <Memory.h>
#include <Aliases.h>
#include <AppleEvents.h>
#include <AERegistry.h>
struct FinderWindow{
long windowType;
DescType aliasType;
long aliasLength;
AliasRecord alias;
};
typedef struct FinderWindow FinderWindow;
pascal OSErr LONG2FWIN( DescType fromType,
Ptr dataPtr,
Size dataSize,
DescType toType,
long refCon,
AEDesc *result)
{
#pragma unused(fromType, dataSize, toType, refCon)
FinderWindow **hFwin;
Size sizH;
long val;
OSErr err;
/* Get the integer value */
val = *(long*)dataPtr;
if (val == 1)
val = 'abot';
else if (val == 2)
val = 'clip';
else
return errAECoercionFail;
/* Allocate the structure */
sizH = 16;
hFwin = (FinderWindow**)NewHandle(sizH);
if (hFwin == 0) return errAECoercionFail;
/* Fill in fields */
(**hFwin).windowType = 0;
(**hFwin).aliasType = 'find';
(**hFwin).aliasLength = 4;
BlockMove((Ptr)(&val), &((**hFwin).alias), 4);
/* Create the descriptor */
MoveHHi((Handle)hFwin);
HLock((Handle)hFwin);
err = AECreateDesc(typeFinderWindow, (Ptr)(*hFwin), sizH, result);
/* Clean up */
DisposeHandle((Handle)hFwin);
return err;
}